import request from '@/utils/request'

export async function login(data) {
  return request({
    url: '/login',
    method: 'post',
    data,
  })
}

export function getUserInfo() {
  return request({
    url: '/getUserInfo',
    method: 'post',
    data: {},
  })
}

export function logout() {
  return request({
    url: '/logout',
    method: 'post',
    data: {},
  })
}

export function register(data) {
  return request({
    url: '/register',
    method: 'post',
    data,
  })
}
// 获取验证码
export function getCode() {
  return request({
    url: '/genKaptcha',
    method: 'get',
  })
}
// 获取省市区树状列表
export function getAreaTree() {
  return request({
    url: '/sysArea/getAreaTree',
    method: 'get',
  })
}
export async function updateUser(params) {
  return request({
    url: '/user/updateWithoutNull',
    method: 'post',
    data: params,
  })
}
export async function resetPassword(params) {
  return request({
    url: '/user/resetPwd',
    method: 'post',
    data: params,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
    },
  })
}
// 修改密码
export function changePassword(oldPwd, newPwd) {
  return request({
    url: '/user/modifyPwd',
    method: 'post',
    data: { oldPwd, newPwd },
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
    },
  })
}
